﻿using ReflectionStudio.Core.Events;
using System;
using System.ComponentModel;
using System.Data;
using System.Windows;
using WPFExcelReport.Helpers; 
namespace WPFExcelReport
{
    public partial class TDEK02
    { 
        public TDEK02()
        {

            if (DesignerProperties.GetIsInDesignMode(this))
                return;
            MV = new VEKKOPF();
            this.DataContext = MV;
            InitializeComponent();
        }
        public override void QueryCommand(object sender, RoutedEventArgs e)
        {
            dwData = TBMain.NewRow();
            dwData["EKKMANDANT"] = app.Mandant;
            SResult = TMV.QEKK99(dwData);
            MergeData(SResult, false);
            base.QueryCommand(sender, e);
        }
        public void ResetSeq(object sender, RoutedEventArgs e)
        {
            //重置供应商流水号为1，EK04,EK05,地址，附加费，VR04/VR05/AB52/WDECK,WBBST,WB14,WBDAT,重置卡号为1
            VSDDAT.SD22.RESETSEQ("0022", KRS, "EKAUFTR", "1");
            dwData = TBMain.NewRow();
            dwData["EKKMANDANT"] = app.Mandant;
            dwData["EKKAUFKRS"] = KRS;
            TMV.DeleteEKKOPF(dwData, 0);
            dwData = TMV.VEKP.TBMain.NewRow();
            dwData["EKPMANDANT"] = app.Mandant;
            dwData["EKPAUFKRS"] = KRS;
            TMV.VEKP.DeleteEKPOS(dwData, 0);
            dwData = TMV.VKD.TBMain.NewRow();
            dwData["VKAMANDANT"] = app.Mandant;
            dwData["VKAAUFKRS"] = KRS;
            dwData["VKASA"] = "EK";
            TMV.VKD.DeleteVKADR(dwData, 0);
            dwData = TMV.VZB.TBMain.NewRow();
            dwData["VKZMANDANT"] = app.Mandant;
            dwData["VKZAUFKRS"] = KRS;
            dwData["VKZSA"] = "EK";
            TMV.VZB.DeleteVKZUAB(dwData, 0);

            dwData = TMV.VRP.TBMain.NewRow();
            dwData["VRPMANDANT"] = app.Mandant;
            dwData["VRPAUFKRS"] = KRS;
            dwData["VRPSTATIST"] = "B";
            TMV.VRP.DeleteVRPOS(dwData, 0);

            dwData = TMV.VRK.TBMain.NewRow();
            dwData["VRKMANDANT"] = app.Mandant;
            dwData["VRKZESSION"] = "B";
            dwData["VRKVERBNR"] = " AND VRKVERBNR LIKE '" + KRS + "%'";
            TMV.VRK.DeleteVRKOPF(dwData, 0);

            dwData = TMV.MU.TBMain.NewRow();
            dwData["ABAMANDANT"] = app.Mandant;
            dwData["ABAVKAUFKRS"] = KRS;
            dwData["ABAVKAUFTYP"] = "B";
            TMV.MU.DeleteABAUFM(dwData, 0);
            dwData = TMV.MU.TBMain.NewRow();
            dwData["ABAMANDANT"] = app.Mandant;
            dwData["ABAAUFKRS"] = KRS;
            dwData["ABAAUFTYP"] = "B";
            TMV.MU.DeleteABAUFM(dwData, 4);

            dwData = TMV.VWD.TBMain.NewRow();
            dwData["WDMANDANT"] = app.Mandant;
            dwData["WDAUFKRS"] = KRS;
            dwData["WDSA"] = "B";
            TMV.VWD.DeleteWDECK(dwData, 0);

            dwData = TMV.WBW.TBMain.NewRow();
            dwData["WBEWMANDANT"] = app.Mandant;
            dwData["WBEWAUFTYP"] = "B";
            dwData["WBEWAUFKRS"] = KRS;
            TMV.WBW.DeleteICC_WBBEW(dwData, 0);
            TMV.WBWT.DeleteWBBEW(dwData, 0);
            dwData = TMV.WBW.VWB.TBMain.NewRow();
            dwData["WBBMANDANT"] = app.Mandant; 
            TMV.WBW.VWB.DWBB00(dwData);
            dwData = TMV.WBW.VWB.VWBD.TBMain.NewRow();
            dwData["WBMANDANT"] = app.Mandant;
            TMV.WBW.VWB.VWBD.DWBD00(dwData);
            dwData = TMV.WBW.VWBD.VWG.TBMain.NewRow();
            dwData["WGMANDANT"] = app.Mandant;
            TMV.WBW.VWB.VWBD.VWG.DWG00(dwData);
            VSDDAT.SD22.RESETSEQ("0022", "  ", "WBDAT", "1"); 
        } 
    }
}
